package com.guochenglang.www.dao.impl;

import com.guochenglang.www.dao.ArticleDao;
import com.guochenglang.www.pojo.Article;
import com.guochenglang.www.service.anotate.Affair;
import com.guochenglang.www.util.GetTable;
import com.guochenglang.www.util.connect.JdbcUtil;

import java.sql.SQLException;
import java.util.ArrayList;

/**
 * 文章表的Dao层
 *
 * @author 郭程朗
 */
public class ArticleDaoImpl implements ArticleDao {
    /**
     * 表名
     */
    private static final String TABLE = GetTable.getTable(Article.class);

    public ArticleDaoImpl() {
    }

    @Override
    public ArrayList<Article> articleSelect(Article article) throws SQLException, InterruptedException, IllegalAccessException, InstantiationException {
        return JdbcUtil.selectMax(TABLE, article);
    }

    @Override
    public ArrayList<Article> articleSelectByLimit(int page, int num, Article article, String order, String mode) throws SQLException, InterruptedException, IllegalAccessException, InstantiationException {
        return JdbcUtil.selectByLimit(TABLE, page, num, article, order, mode);
    }


    @Override
    public int insertArticle(Article article) throws SQLException, InterruptedException, IllegalAccessException {
        return JdbcUtil.insert(TABLE, article);
    }

    @Override
    public int updateArticle(Article set, Article conditions) throws SQLException, InterruptedException, IllegalAccessException {
        return JdbcUtil.update(TABLE, set, conditions);
    }

    @Override
    public int deleteArticle(Article conditions) throws SQLException, InterruptedException, IllegalAccessException {
        return JdbcUtil.delete(TABLE, conditions);
    }
}
